Referring to FIG. 1, a persistent connection is established between an application installed on a terminal and a remote application server by using a network. If there is no data communication over the persistent connection in a specific time period, a core network disconnects the persistent connection. Therefore, the application needs to maintain the persistent connection to the application server by using a heartbeat mechanism. The heartbeat mechanism is periodical transmission of a heartbeat packet between a terminal and a server, so as to ensure a normal persistent connection. For example, the terminal sends a heartbeat packet to the server at a regular interval. If the server responds to the heartbeat packet in a specific time period, it indicates that the terminal is normally connected to the server. If the server does not respond to the heartbeat packet in a specific time period, it indicates that the terminal is disconnected from the server. After the disconnection is learned, remedial actions, such as fault detection and reconnection, may be used. Alternatively, a heartbeat service may be implemented in a manner in which the server actively sends a heartbeat packet to the terminal, or in another manner.
The application generally has a preset heartbeat period to meet a need of a current application service. If applications on the terminal have different heartbeat start points and periods, the terminal needs to wake up a modem of the terminal for multiple times at different time points to establish a Radio Resource Control (RRC) connection to a base station, and send a single heartbeat packet to each application server, which results in relatively huge energy consumption and a relatively great waste of signaling.
If all applications perform heartbeat services by using a same heartbeat period, multiple heartbeat packets may be sent by using one RRC connection, so that the energy consumption and the waste of signaling are effectively reduced. However, how to determine a proper heartbeat period is a problem to be urgently resolved. If an excessively short heartbeat period is set, the heartbeat service is frequently performed, and consumption of energy and signaling is relatively huge. If an excessively great heartbeat period is set, the heartbeat period may exceed a heartbeat period threshold of the application server or the core network, which causes a disconnection, and an interruption of the heartbeat service.